package com.itbaizhan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itbaizhan.mapper1.AccountInfoMapper;
import com.itbaizhan.pojo.AccountInfo;
import com.itbaizhan.service.AccountInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
* @author 13487
* @description 针对表【account_info】的数据库操作Service实现
* @createDate 2024-04-13 15:55:36
*/
@Service
public class AccountInfoServiceImpl extends ServiceImpl<AccountInfoMapper, AccountInfo>
    implements AccountInfoService {

    @Autowired
    private AccountInfoMapper accountInfoMapper;

    @Override
    @Transactional
    public void transfer(String accountNo, double amount) {
        QueryWrapper<AccountInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("account_no", accountNo);
        AccountInfo accountInfo = accountInfoMapper.selectOne(queryWrapper);
        if (accountInfo != null){
            accountInfo.setAccountBalance(accountInfo.getAccountBalance() + amount);
            accountInfoMapper.updateById(accountInfo);
        }
    }
}




